﻿using RockBus.Composition.Interfaces;
using RockBus.ConfigurationService.Interfaces;
using RockBus.DataContracts;
using RockBus.Logging.Interfaces;
using RockBus.Routing.Interfaces;
using System;
using System.Reflection;
using System.ServiceModel;

namespace RockBus.Services
{
    public partial class ConfigurationService :
        IConfigurationService,
        IConfigurationServiceOneWay
    {
        public static ILogger Logger = DependencyManager.Instance.Resolve<ILogger>();

        public static IConfigurationManager ConfigurationManager = DependencyManager.Instance.Resolve<IConfigurationManager>();

        #region IConfigurationService

        SubscriberConfiguration IConfigurationService.GetSubscriberConfiguration()
        {
            return ConfigurationManager.GetSubscriberConfiguration();
        }

        RockBusAck IConfigurationService.AddOrUpdateSubscribers(AddOrUpdateSubscribersRequest request)
        {
            return ConfigurationManager.AddOrUpdateSubscribers(request);
        }

        RockBusAck IConfigurationService.RemoveSubscribers(RemoveSubscribersRequest request)
        {
            return ConfigurationManager.RemoveSubscribers(request);
        }

        RockBusAck IConfigurationService.RemoveSubscriptions(RemoveSubscriptionsRequest request)
        {
            return ConfigurationManager.RemoveSubscriptions(request);
        }

        PublisherConfiguration IConfigurationService.GetPublisherConfiguration()
        {
            return ConfigurationManager.GetPublisherConfiguration();
        }

        AddOrUpdatePublishersResponse IConfigurationService.AddOrUpdatePublishers(AddOrUpdatePublishersRequest request)
        {
            return ConfigurationManager.AddOrUpdatePublishers(request);
        }

        RockBusAck IConfigurationService.RemovePublishers(RemovePublishersRequest request)
        {
            return ConfigurationManager.RemovePublishers(request);
        }

        RockBusAck IConfigurationService.RemoveReceivePorts(RemoveReceivePortsRequest request)
        {
            return ConfigurationManager.RemoveReceivePorts(request);
        }

        RockBusAck IConfigurationService.RemoveAllSubscribers(RemoveAllSubscribersRequest request)
        {
            return ConfigurationManager.RemoveAllSubscribers(request);
        }

        RockBusAck IConfigurationService.RemoveAllPublishers(RemoveAllPublishersRequest request)
        {
            return ConfigurationManager.RemoveAllPublishers(request);
        }

        GetInternalConfigurationResponse IConfigurationService.GetInternalConfiguration(GetInternalConfigurationRequest request)
        {
            return ConfigurationManager.GetInternalConfiguration(request);
        }

        RockBusAck IConfigurationService.SetInternalConfiguration(SetInternalConfigurationRequest request)
        {
            return ConfigurationManager.SetInternalConfiguration(request);
        }

        #endregion IConfigurationService

        #region IConfigurationServiceOneWay

        void IConfigurationServiceOneWay.AddOrUpdateSubscribers(AddOrUpdateSubscribersRequest request)
        {
            ConfigurationManager.AddOrUpdateSubscribers(request);
        }

        void IConfigurationServiceOneWay.RemoveSubscribers(RemoveSubscribersRequest request)
        {
            ConfigurationManager.RemoveSubscribers(request);
        }

        void IConfigurationServiceOneWay.RemoveSubscriptions(RemoveSubscriptionsRequest request)
        {
            ConfigurationManager.RemoveSubscriptions(request);
        }

        void IConfigurationServiceOneWay.AddOrUpdatePublishers(AddOrUpdatePublishersRequest request)
        {
            ConfigurationManager.AddOrUpdatePublishers(request);
        }

        void IConfigurationServiceOneWay.RemovePublishers(RemovePublishersRequest request)
        {
            ConfigurationManager.RemovePublishers(request);
        }

        void IConfigurationServiceOneWay.RemoveReceivePorts(RemoveReceivePortsRequest request)
        {
            ConfigurationManager.RemoveReceivePorts(request);
        }

        void IConfigurationServiceOneWay.RemoveAllSubscribers(RemoveAllSubscribersRequest request)
        {
            ConfigurationManager.RemoveAllSubscribers(request);
        }

        void IConfigurationServiceOneWay.RemoveAllPublishers(RemoveAllPublishersRequest request)
        {
            ConfigurationManager.RemoveAllPublishers(request);
        }

        void IConfigurationServiceOneWay.SetInternalConfiguration(SetInternalConfigurationRequest request)
        {
            ConfigurationManager.SetInternalConfiguration(request);
        }

        #endregion IConfigurationServiceOneWay
    }
}